#include "MsgQueue.hpp"
#include <boost/thread.hpp>
#include <boost/timer.hpp>

int main(int, char *[])
{
    boost::timer t;
    CBufList lst;
    CBufQueue que;
    IMediaBuffer *buf = 0, *tmp = 0;
    buf = new IMediaBuffer();
    int i = 0, j = 0;
    t.restart();
    for ( i = 0; i < 100; ++i )
    {
        for ( j = 0; j < 500; ++j )
        {
            que.push( buf );
        }
        for ( j = 0; j < 500; ++j )
        {
            if ( !que.pop( tmp ) )
                std::cout << "que pop a buf failed!\n";
        }
    }
    std::cout << "CBufQueue:" << t.elapsed() << std::endl;
    t.restart();
    for ( i = 0; i < 100; ++i )
    {
        for ( j = 0; j < 500; ++j )
        {
            lst.push( buf );
        }
        for ( j = 0; j < 500; ++j )
        {
            if ( !lst.pop( tmp ) )
                std::cout << "que pop a buf failed!\n";
        }
    }
    std::cout << "CBufList:" << t.elapsed() << std::endl;
    delete buf;
    buf = 0;
    return 0;
};